import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/17 9:21
 * @description
 */
public class Solution2 {
    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();
        int[] arr = {1, 0, 2, 3, 0, 4, 5, 0};
        solution2.duplicateZeros(arr);
    }
    public void duplicateZeros(int[] arr) {
        int n = arr.length;
        for(int i = 0; i < n; i++) {
            if(arr[i] == 0) {
                for(int j = n - 1; j >= i + 1; j--) {
                    arr[j] = arr[j - 1];
                }
                if(i + 1 < n) {
                    arr[i + 1] = 0;
                }
                i = i + 1;
            }
        }
    }
}
